
/**
 * 创建ext对象的方法  numberfield  textfield等等
 * @param first
 * @param i_id
 * @param i_type
 * @param i_x
 * @param i_y
 * @param i_width
 * @param i_height
 * @param object
 * @return
 */
PPdesinger.prototype.createExtItem = function(first,obj)
//PPdesinger.prototype.createExtItem = function(first,i_id,i_type,i_x,i_y,i_width,i_height,object)
{
	
	switch (obj.i_type) 
	{
		case "select":
			var allItems=obj.i_items;
			if(typeof(obj.i_items)=="string")
				allItems = eval(obj.i_items);
			var selectBox = new Ext.form.ComboBox({
					id:obj.i_id,
					name:obj.i_code,
					//tabIndex:i_tabseq,
					height:parseInt(obj.i_height),
					width:parseInt(obj.i_width),
					x:parseInt(obj.i_x),
					y:parseInt(obj.i_y),
				    typeAhead: true,
				    triggerAction: 'all',
				    lazyRender:true,
				    mode: 'local',
				    allowBlank:eval(obj.i_allowblank),
				    blankText:'不允许为空',
				    readOnly : eval(obj.i_readonly),
				    store:new Ext.data.Store({
				    	autoLoad:true,
				    	reader: new Ext.data.JsonReader({}, [{name: 'boxLabel'},{name:'name'},{name:'columnWidth'}]),
				    	//data:[{boxLabel:"字符",name:"1"},{boxLabel:"数字",name:"2"},{boxLabel:"文本",name:"3"},{boxLabel:"日期",name:"4"}]
				    	data:allItems
				    }),
				    valueField: 'name',
				    displayField: 'boxLabel'
				});
				return selectBox;
				break;
		case "button":
			//eval("var myfunction = "+obj.i_function);
			 var button_ =  new Ext.Button({
				 	id:obj.i_id,
			        text:obj.i_text,
			        height:parseInt(obj.i_height),
					width:parseInt(obj.i_width),
					x:parseInt(obj.i_x),
					y:parseInt(obj.i_y)
			       // handler: myfunction
			    });
			 if(!this.howCreateForm.isModifyForm&&!this.howCreateForm.isNewForm)
				 button_.setHandler(function(){eval(obj.i_function);});
			 return button_;
			break;
		case "checkbox":
			var allItems=obj.i_items;
			if(typeof(obj.i_items)=="string")
				allItems = eval(obj.i_items);
			var myCheckboxGroup =  new Ext.form.FieldSet({
				 id:obj.i_id,
				 height:parseInt(obj.i_height)+22,
				 width:parseInt(obj.i_width)+22,
				 x:parseInt(obj.i_x),
				 y:parseInt(obj.i_y),
				  autoHeight:false,
				 defaultType: 'checkbox',
				 layout: 'column',
				 items:allItems
			});
			return myCheckboxGroup;
			break;
		case "radiobox":
			var allItems=obj.i_items;
			if(typeof(obj.i_items)=="string")
				allItems = eval(obj.i_items);
			var myRadioGroup = new Ext.form.FieldSet({
				 id:obj.i_id,
				 height:parseInt(obj.i_height)+22,
				 width:parseInt(obj.i_width)+22,
				 x:parseInt(obj.i_x),
				  autoHeight:false,
				 y:parseInt(obj.i_y),
				 defaultType: 'radio',
				 layout: 'column',
				 items:allItems
			});
			return myRadioGroup;
			break;
		case"htmleditor":
			var htmlEditor;

			if((first||this.howCreateForm.isModifyForm)&&this.howCreateForm.isRedisplayForm==false)
			{
				htmlEditor = new  Ext.form.HtmlEditor({
				id:obj.i_id,
				x:parseInt(obj.i_x),
				y:parseInt(obj.i_y),
				value:obj.i_value,
				i_type:obj.i_type,
				height:parseInt(obj.i_height),
				width:parseInt(obj.i_width)
				});
				//htmlEditor.setValue(obj.i_value);
			}
			else
			{
				htmlEditor = new  Ext.form.HtmlEditor({
					id:obj.i_id,
					x:parseInt(obj.i_x),
					y:parseInt(obj.i_y),
					i_type:obj.i_type,
					height:parseInt(obj.i_height),
					width:parseInt(obj.i_width),
					enableAlignments:false,
					enableColors:false,
					enableFont :false,
					enableFontSize :false,
					enableFormat:false,
					enableLinks:false,
					enableLists:false,
					value:obj.i_value,
					enableSourceEdit :false
					});
				//htmlEditor.setValue(obj.i_value);
			}
			return htmlEditor;
		case "label":
			var label;
			if(first)
			{
				style='color:#000000;font: normal normal 12px 宋体;';
				label = new  Ext.form.Label({
					text:obj.i_value,
					x:parseInt(obj.i_x),
					style:style,
					i_type:obj.i_type,
					y:parseInt(obj.i_y),
					id:obj.i_id,
					width:parseInt(obj.i_width),
					height:parseInt(obj.i_height)
				});
				
			}
			else
			{
				
			}
			return label;
		case "numberfield" :
			var numberfield;
			if(first)
			{
				numberfield = new Ext.form.NumberField({
				 	blankText:'内容不允许为空',
					id:obj.i_id,
					x:parseInt(obj.i_x),
					y:parseInt(obj.i_y),
					tabIndex:obj.i_tabseq,
					height:parseInt(obj.i_height),
					width:parseInt(obj.i_width),
					name:obj.i_id,
					confirmTo:'',
					vtypeText:'',
					readOnly : eval(obj.i_readonly),
					allowDecimals:true,
				//	emptyText:obj.i_value,
					value:obj.i_value,
					nanText  :'数据不合法！',
					maxLength:obj.i_length,//能够输入的内容的最大长度
	  				maxLengthText:"输入内容太长了,超过了最大长度",//超出最大长度的设置信息
	  				autoCreate: {tag: 'input', type: 'text', autocomplete: 'off', maxlength: 100},//超出长度后截断，不允许再输入
	  				allowBlank: eval(obj.i_allowblank)
				});
			}
			else
			{	
				
			}
			return numberfield;
		case "textfield":
			var textfield;
			if(first)
			{
				textfield = new Ext.form.TextField({
	                allowBlank: eval(obj.i_allowblank),
	                blankText:'内容不允许为空',
					id:obj.i_id,
					x:parseInt(obj.i_x),
					y:parseInt(obj.i_y),
					tabIndex:obj.i_tabseq,
					height:parseInt(obj.i_height),
					width:parseInt(obj.i_width),
					name:obj.i_id,
					confirmTo:'',
					nanText:'数据不合法！',
					vtypeText:'',
					readOnly : eval(obj.i_readonly),
					value:obj.i_value,
				//	emptyText:obj.i_value,
					maxLength:obj.i_length,//能够输入的内容的最大长度
	  				maxLengthText:"输入内容太长了,超过了最大长度",//超出最大长度的设置信息
	  				autoCreate: {tag: 'input', type: 'text', autocomplete: 'off', maxlength: 100},//超出长度后截断，不允许再输入
					inputType:'text'
	            });
			}
			else
			{
				
			}
			return textfield;
		case "datefield":
			var datefield;
			if(first)
			{
				datefield = new Ext.form.DateField({
					allowBlank: eval(obj.i_allowblank),
					format:'Y-m-d',
					id:obj.i_id,
					blankText:'内容不允许为空',
					x:parseInt(obj.i_x),
					y:parseInt(obj.i_y),
					autoWidth:false,
					name:obj.i_id,
					nanText:'数据不合法！',
					tabIndex:obj.i_tabseq,
					readOnly : eval(obj.i_readonly),
					height:parseInt(obj.i_height),
					width:parseInt(obj.i_width)
	             });
			}
			else
			{
				
			}
			return datefield;
		case "textarea":
			var textarea;
			if(first)
			{
				textarea = new Ext.form.TextArea({
					allowBlank: eval(obj.i_allowblank),
					id:obj.i_id,
					x:parseInt(obj.i_x),
					blankText:'内容不允许为空',
					confirmTo:'',
					vtypeText:'',
					name:obj.i_id,
					nanText:'数据不合法！',
					//hiddenName:i_code,
					maxLength:obj.i_length,//能够输入的内容的最大长度
					width:parseInt(obj.i_width),
					tabIndex:obj.i_tabseq,
					y:parseInt(obj.i_y),
					height:parseInt(obj.i_height),
					readOnly : eval(obj.i_readonly),
					value:obj.i_value,
					emptyText:obj.i_value
				});
			}
			else
			{
				
			}
			return textarea;
			
	}
};

